package net.chenyan.server.repository;/**
 * @author chenyan
 * @createTime 2022/5/13 17:21
 * @description description
 */

import net.chenyan.server.po.Singer;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.Pageable;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;
import org.springframework.stereotype.Repository;

/**
 *@description: TODO
 *@author: chenyan
 *@create: 2022/5/13 17:21
 */
@Repository
public interface SingerRepository extends PagingAndSortingRepository<Singer,Integer>, JpaSpecificationExecutor<Singer> {

    //分页查询（根据用户id分页查询所有用户收藏的数据）
    @Query(value = "select s.*  from user_singer us inner join user u on u.id=us.user_id inner join singer s on s.id=us.singer_id where user_id=?1",nativeQuery = true)
    Page<Singer> findSingerByUserId(int userId, Pageable pageable);
}
